Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-5014 Fix handling of async socket errors in kms request #2054

Merged
merged 6 commits into from
Jan 10, 2025

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Jan 10, 2025

This addresses the MacOS encryption errors but not yet the Encryption PyOpenSSL errors.
It addresses the Encryption PyOpenSSL error by expanding the regex to include "SSL handshake failed".

@blink1073 blink1073 requested a review from ShaneHarvey January 10, 2025 14:57
@@ -213,6 +213,9 @@ async def kms_request(self, kms_context: MongoCryptKmsContext) -> None:
if not data:
raise OSError("KMS connection closed")
kms_context.feed(data)
# Async raises an OSError instead of returning empty bytes
except OSError as err:
raise OSError("KMS connection closed") from err
Copy link
Member

@ShaneHarvey ShaneHarvey Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't OSError already get handled by the except Exception as exc block? It should hit the _raise_connection_failure line which adds important info to the error message like the host/port/connection timeouts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@blink1073 blink1073 requested a review from ShaneHarvey January 10, 2025 18:12
@ShaneHarvey
Copy link
Member

I wonder if some of this logic can be removed after the async streams/protocol work is merged?

@blink1073 blink1073 merged commit 493fc2a into mongodb:master Jan 10, 2025
49 of 51 checks passed
@blink1073 blink1073 deleted the PYTHON-5014 branch January 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants